package com.bt.lms.ui.page.common;

import com.bt.lms.ui.page.common.action.pageteaching.*;
import com.bt.lms.ui.vo.PageSkipInfo;
import com.bt.lms.ui.page.course.CourseInfoList;
import com.bt.lms.main.BotLmsApp;
import com.bt.lms.ui.page.sys.style.BoxStyle;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Accordion;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;


/**
 * 教学管理索引界面
 */
public class PageTeaching extends HBox {


    /**
     * 构建界面
     */
    public PageTeaching() {

        //布局
        Insets insets = new Insets(10);
        this.setPadding(insets);
        this.setSpacing(10);
        this.setPrefWidth(1480);

        //索引部分
        VBox indexesVBox = new VBox();
        indexesVBox.setPrefWidth(PageCommon.TWO_WIGHT);
        indexesVBox.setMinHeight(BotLmsApp.HEIGHT);
        indexesVBoxInit(indexesVBox);
        this.getChildren().add(indexesVBox);
        //背景色
        BoxStyle.mainBackdrop(indexesVBox);

        CourseInfoList pageCourseInfoList = new CourseInfoList();//课程管理列表页
        this.getChildren().add(pageCourseInfoList);
    }

    /**
     * 索引部分初始化
     *
     * @param menuVBox 菜单盒子
     */
    private void indexesVBoxInit(VBox menuVBox) {

        //组件（选项所在容器）
        VBox teachingVBox = new VBox();
        //容器初始化
        teachingVBoxInit(teachingVBox);
        //背景色
        BoxStyle.mainBackdrop(teachingVBox);

        //菜单组件（手风琴）
        TitledPane titledPane = new TitledPane("教学管理", teachingVBox);
        titledPane.setExpanded(true);//默认展开
        titledPane.setAnimated(false);//展开动画禁止

        Accordion accordion = new Accordion();
        accordion.setExpandedPane(titledPane);
        accordion.getPanes().add(titledPane);

        //添加组件
        ObservableList<Node> children = menuVBox.getChildren();
        children.addAll(accordion);
    }

    /**
     * 教学管理选项初始化
     *
     * @param teachingVBox 教学管理盒子
     */
    private void teachingVBoxInit(VBox teachingVBox) {

        //组件数据组件统一默认高
        int height = 40;
        //界面跳转对象
        PageSkipInfo pageSkipInfo = new PageSkipInfo();
        pageSkipInfo.setPane(this);
        pageSkipInfo.setIndex(1);

        //布局
        teachingVBox.setSpacing(2);

        //组件
        Label courseLab = new Label("课程管理");
        courseLab.setPrefHeight(height);
        //组件添加
        teachingVBox.getChildren().add(courseLab);
        //事件
        CourseLabLabAction courseLabLabAction = new CourseLabLabAction(pageSkipInfo);
        courseLab.setOnMouseClicked(courseLabLabAction);
        //小手图案
        courseLab.setCursor(Cursor.HAND);

        //组件
        Label teachingPlanLab = new Label("教学计划管理");
        teachingPlanLab.setPrefHeight(height);
        //组件添加
        teachingVBox.getChildren().add(teachingPlanLab);
        //事件
        TeachingPlanLabAction teachingPlanLabAction = new TeachingPlanLabAction(pageSkipInfo);
        teachingPlanLab.setOnMouseClicked(teachingPlanLabAction);
        //小手图案
        teachingPlanLab.setCursor(Cursor.HAND);

        //组件
        Label teacherLab = new Label("教师管理");
        teacherLab.setPrefHeight(height);
        //组件添加
        teachingVBox.getChildren().add(teacherLab);
        //事件
        TeacherLabAction teacherLabAction = new TeacherLabAction(pageSkipInfo);
        teacherLab.setOnMouseClicked(teacherLabAction);
        //小手图案
        teacherLab.setCursor(Cursor.HAND);

        //组件
        Label teachingArrangeLab = new Label("教学安排");
        teachingArrangeLab.setPrefHeight(height);
        //组件添加
        teachingVBox.getChildren().add(teachingArrangeLab);
        //事件
        TeachingArrangeLabAction teachingArrangeLabAction = new TeachingArrangeLabAction(pageSkipInfo);
        teachingArrangeLab.setOnMouseClicked(teachingArrangeLabAction);
        //小手图案
        teachingArrangeLab.setCursor(Cursor.HAND);

        //组件
        Label teachingSuperLab = new Label("教学监管");
        teachingSuperLab.setPrefHeight(height);
        //组件添加
        teachingVBox.getChildren().add(teachingSuperLab);
        //事件
        TeachingSuperLabAction teachingSuperLabAction = new TeachingSuperLabAction(pageSkipInfo);
        teachingSuperLab.setOnMouseClicked(teachingSuperLabAction);
        //小手图案
        teachingSuperLab.setCursor(Cursor.HAND);

    }
}
